package com.hmall.controller;

import com.hdmall.business.common.annotation.LoginRequired;
import com.hdmall.business.common.common.Const;
import com.hdmall.business.common.common.ResponseCode;
import com.hdmall.business.common.common.ServerResponse;
import com.hdmall.business.common.util.HttpClientUtil;
import com.hmall.mapper.MallOrderMapper;
import com.hmall.mapper.SysDeptCustomerMapper;
import com.hmall.model.MallDistmode;
import com.hmall.model.MallPaymentType;
import com.hmall.model.SysUser;
import com.hmall.service.*;
import com.hmall.util.TokenUtil;
import com.hmall.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.OrderedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.*;

@RestController
@RequestMapping("order/")
@Api(value = "订单操作API", description = "订单类操作API说明-v2")
public class OrderController {

    @Autowired
    private BiUserActionHistoryService biUserActionHistoryService;


    @Autowired
    private OrderService iOrderService;

    @Autowired
    private ShippingService shippingService;

    @Autowired
    private DistModeService distModeService;

    @Autowired
    private ContService contService;

    @Autowired
    private UserService userService;

    @Autowired
    private PaymentTypeService paymentTypeService;

    @Autowired
    private PaymentService paymentService;

    @Autowired
    private UpDownServiceImpl upDownService;

    @Autowired
    private SysDeptCustomerMapper sysDeptCustomerMapper;

    @Autowired
    private MallOrderMapper orderMapper;

    @Autowired
    private JedisPool jedisPool;

    private TokenUtil tokenUtil = new TokenUtil();

    /**
     * louxinlong
     * 购物车中购买生成订单
     * @param shippingId
     * @param  @RequestBody List<CartProductTempVo> list 废弃
     * @return
     * @throws Exception
     */
    @LoginRequired
    @PostMapping("cartCreate")
    @ApiOperation(value = "在购物车创建订单", notes = "2018/10/23 自提订单需要传入自提信息")
    public ServerResponse<List<OrderSelectVo>> cartCreate(String token, Integer shippingId, Integer distId,Integer paymentType,
        String message,String invoiceRecPerson,String invoiceRecPhone,String invoiceRecAddress, Integer transportId) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        String agent = tokenUtil.getAgent(token).split("-")[0];
       return iOrderService.cartCreate(agent, user.getUserId(), shippingId, distId, paymentType, message, invoiceRecPerson, invoiceRecPhone, invoiceRecAddress, transportId);

    }

    //订单完成 设置状态 调用评论接口
    @GetMapping("completCommendOrder")
    @ApiOperation(value = "订单完成已收货并更新评论")
    public ServerResponse completCommendOrder(Integer orderId,Long orderNo){
            Map<String,String> map=new HashMap<String,String>();
            map.put("orderId",orderId.toString());
            //开发
           String result=HttpClientUtil.doGetWithParam("http://47.98.171.71:9094/comment/createDefaultComment",map);
            // 测试
//             String result=HttpClientUtil.doGetWithParam("http://47.98.169.251:9094/comment/createDefaultComment",map);
            iOrderService.updateStatus(orderNo,50);
            return ServerResponse.createBySuccess();

    }
    //修改订单状态
    @GetMapping("updateOrder")
    @ApiOperation(value = "修改订单状态")
    public ServerResponse updateOrder(Long orderNo,Integer status){

        return iOrderService.updateStatus(orderNo,status);
    }

    @LoginRequired
    @PostMapping("selectAllDistMode")
    @ApiOperation(value = "查询所有配送方式")
    public ServerResponse<List<MallDistmode>> selectAllDistMode(String token) throws Exception {

        return  distModeService.selectAllDistModes();

    }
    @LoginRequired
    @PostMapping("selectDistModeById")
    @ApiOperation(value = "按id查询配送方式")
    public ServerResponse selectDistModeById(String token,Integer distId) throws Exception {

        return  distModeService.selectById(distId);

    }
    @LoginRequired
    @PostMapping("setDistModeChecked")
    @ApiOperation(value = "设置配送选中状态")
    public ServerResponse<Integer> setDistModeChecked(String token,Integer distId,Integer checked) throws Exception {

        return  distModeService.updateCheck(distId,checked);

    }

    @LoginRequired
    @PostMapping("cancelOrder")
    @ApiOperation(value = "取消订单")
    public ServerResponse cancelOrder(String token, Long orderNo) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return  iOrderService.cancel(user.getUserId(), orderNo);
    }

    /**
     * 创建订单0:快捷购买 1:拿样
     * @param token
     * @param isSample
     * @param shippingId
     * @param distId
     * @param productId
     * @param weight
     * @param grade
     * @return
     * @throws Exception
     */
    @LoginRequired
    @PostMapping("createSampleOrQuick")
    @ApiOperation(value = "拿样，快捷购买")
    public ServerResponse<OrderSelectVo> createSampleOrQuick(String token,Integer isSample, Integer shippingId,Integer distId,  Integer productId, BigDecimal weight, String grade,
        String message,String invoiceRecPerson,String invoiceRecPhone,String invoiceRecAddress, Integer transportId) throws Exception {
        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        //看是不是绑定办事处 如果null 没有绑定办事处
        //逻辑修改
        Integer dealerId= userService.selectDealerId(user.getUserId()).getData();
        //增加验证是否有商家绑定信息
        SysDeptVo buyerDept=userService.findBuyerDept(user.getUserId()).getData();
        String agent = tokenUtil.getAgent(token).split("-")[0];
        //订货生成订单
        return  iOrderService.createOrderSimpleOrQuick2(agent, isSample,user.getUserId(), shippingId,  productId, weight, grade,distId,
                message,invoiceRecPerson,invoiceRecPhone,invoiceRecAddress, dealerId, transportId);
    }

    @LoginRequired
    @PostMapping("getSampleCount")
    @ApiOperation(value = "获取本月拿样次数")
    public ServerResponse getSampleCount(String token) throws Exception {
        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        Calendar calendar = Calendar.getInstance();
        Integer year = calendar.get(Calendar.YEAR);
        Integer month = calendar.get(Calendar.MONTH);
        calendar.set(year, month, 1, 0, 0, 0);
        calendar.set(Calendar.MILLISECOND, 0);
        Date start = calendar.getTime();
        calendar.set(Calendar.MONTH, month + 1);
        Date end = calendar.getTime();
        Integer customerId = sysDeptCustomerMapper.selectCustomerIdByCustomerUserId(user.getUserId());
        Integer sampleCount = orderMapper.selectSampleWithCustomerId(customerId, start, end);
        return ServerResponse.createBySuccess(sampleCount);
    }

    /**
     * 订单号显示合同
     * @param token
     * @return
     * @throws Exception
     */
    @Deprecated
    @LoginRequired
    @PostMapping("selectOrderSalesCont")
    @ApiOperation(value = "用户查询合同")
    public ServerResponse<String> selectOrderSalesCont(String token,String contNo) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        //订单号回显合同条款，订单对象和产品等内容
        return  contService.selectImgUrlContByContNo(user.getUserId(),contNo);

    }

    /**
     *生成销售合同 回显
     * @param token
     * @param orderNo
     * @return
     * @throws Exception
     */
    @Deprecated
    @LoginRequired
    @PostMapping("createOrderShowSalesCont")
    @ApiOperation(value = "生成销售合同--回显合同板式")
    public ServerResponse<String> createOrderShowSalesCont(String token,Long orderNo) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return  contService.pdfShowSalesContUrl(user.getUserId(),orderNo);

    }
    /**
     *生成销售合同 是否同意 1 yes 2 no
     * @param token
     * @param orderNo
     * @return
     * @throws Exception
     */
    @Deprecated
    @LoginRequired
    @PostMapping("createOrderAgreeSalesCont")
    @ApiOperation(value = "生成销售合同--是否同意")
    public ServerResponse<OrderSalseUrlVo> createOrderAgreeSalesCont(String token, Long orderNo, @RequestParam(value="isAgree",defaultValue ="1") Integer isAgree) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return  contService.salesContIsAgree(user.getUserId(),orderNo,isAgree);
    }

    /**
     * 订单详情 lou
     * @param token
     * @param orderNo
     * @return
     * @throws Exception
     */

    //后期优化，自己只能看见自己的订单

    @LoginRequired
    @GetMapping("selectOrderByOrderNo")
    @ApiOperation(value="订单详情")
    public ServerResponse<OrderSelectVo> selectOrderByOrderNo(String token, Long orderNo) throws Exception{

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return  iOrderService.selectOrderByOrderNo(user.getUserId(),orderNo);
    }


    /**
     * 获取用户订单列表包括订单产品项
     * @param pageNo
     * @param pageSize
     * @param token
     * @param status
     * @return
     */
    @LoginRequired
    @GetMapping("getUserOderItems")
    @ApiOperation(value="获取用户订单列表包括订单产品项，全部1 待审核10 待发货20 已发货60 交易完成50 已取消0 对账单产品列表100(作兼容 包括已发货+已完成的订单)", notes = "改支持筛选订单编号以及类型")
    public ServerResponse<PageVo> getUserOderItems(String token, @RequestParam(value="pageNo",defaultValue ="1" )Integer pageNo, @RequestParam(value="pageSize",defaultValue ="10" )Integer pageSize, @RequestParam(value="status",defaultValue ="1" )String status
                        ,String orderNo, String type) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return iOrderService.getOrderItemsList(status, user.getUserId(), pageNo, pageSize, orderNo, type);
    }


    @LoginRequired
    @Deprecated
    @PostMapping("unionpay")
    @ApiOperation(value = "银联支付")
    public ServerResponse unionpay(String token,Long orderNo,HttpServletResponse resp)throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        //暂用，根据订单编号来改变订单状态为发货
        iOrderService.changeOrderStatusByOrderNum(orderNo, 20);

        return iOrderService.unionpay(orderNo,user.getUserId(),resp);
    }

    @LoginRequired
    @Deprecated
    @PostMapping("appunionpay")
    @ApiOperation(value = "手机银联支付")
    public ServerResponse appunionpay(String token,Long orderNo,HttpServletResponse resp)throws Exception{

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return iOrderService.appunionpay(orderNo,user.getUserId(),resp);
    }

    @Deprecated
    @PostMapping("query")
    @ApiOperation(value = "交易查询")
    public ServerResponse query(String merId,String orderId)throws ServletException,IOException{

        return iOrderService.query(merId,orderId);
    }

    @PostMapping("apprefund")
    @ApiOperation(value = "银联退款")
    public ServerResponse apprefund(String merId,String txnAmt,String origQryId)throws ServletException,IOException{

        return iOrderService.apprefund(merId,txnAmt,origQryId);
    }

    @Deprecated
    @PostMapping("refund")
    @ApiOperation(value = "银联退款")
    public ServerResponse refund(String merId,String txnAmt,String origQryId)throws ServletException,IOException{

        return iOrderService.refund(merId,txnAmt,origQryId);
    }

    @Deprecated
    @GetMapping("query_order_pay_status")
    @ApiOperation(value="查询支付状态")
    public ServerResponse<Boolean> queryOrderPayStatus(HttpSession session, Long orderNo){

        SysUser user = (SysUser)session.getAttribute(Const.CURRENT_USER);
        if(user ==null){
            return ServerResponse.createByErrorCodeMessage(ResponseCode.NEED_LOGIN.getCode(), ResponseCode.NEED_LOGIN.getDesc());
        }

        ServerResponse serverResponse = iOrderService.queryOrderPayStatus(user.getUserId(),orderNo);
        if(serverResponse.isSuccess()){
            return ServerResponse.createBySuccess(true);
        }
        return ServerResponse.createBySuccess(false);
    }

    @Deprecated
    @LoginRequired
    @GetMapping("getFreight")
    @ApiOperation(value = "获得运费", notes = "根据所选的地区来计算出运费")
    public ServerResponse<List<MallFreightVo>> getFreight(String token, Integer shippingId){

        return iOrderService.getFreight(shippingId);
    }
    
    @LoginRequired
    @Deprecated
    @DeleteMapping("Test_deleteOrder")
    @ApiOperation(value = "删除订单和订单明细", notes = "方便前端进行订单的删除")
    public ServerResponse deleteOrder(String token,Long orderNo) throws Exception {

        return iOrderService.deleteOrderByOrderNo(orderNo);
    }

    //改变订单状态接口
    @PostMapping("changeOrderStatus")
    @Deprecated
    @ApiOperation(value = "改变订单状态", notes = "传入订单的id和要传入的状态作修改")
    public ServerResponse changeOrderStatus(Integer orderId, Integer status){

        return iOrderService.changeOrderStatus(orderId, status);
    }

    //查看某个用户的所有订单id以及订单状态
    @LoginRequired
    @GetMapping("findOrderStatus")
    @ApiOperation(value = "查看某个用户的所有订单id以及订单状态", notes = "为改变订单状态提供信息")
    public ServerResponse<Map<Integer, Integer>> findOrderStatus(String token) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return iOrderService.findOrderStatus(user.getUserId());
    }

    //查询所有支付方式
    @GetMapping("selectPaymentTypes")
    @ApiOperation(value = "查看所有支付方式")
    public ServerResponse<List<MallPaymentType>> selectPaymentTypes() throws Exception {
        return  paymentTypeService.selectPaymentTypes();
    }



    //客户线下账期支付提交凭证信息
    //暂时取消账期，只有交易流水号和交易凭证
    @LoginRequired
    @Deprecated
    @PostMapping("underLineAccountPeriodPay")
    @ApiOperation(value = "客户线下账期支付提交凭证信息")
//,Integer accountPeriod,Double interestRate
    //transactionNo  流水号
    //订单编号
    //付款凭证
    //
    public ServerResponse<AccountPeriodPayVo> underLineAccountPeriodPay(String token,String transactionNo,Long orderNo,String voucherImg,@RequestParam(value = "paymentType",defaultValue = "1") Integer paymentType ) throws Exception {
        Jedis jedis = jedisPool.getResource();
        SysUser user = tokenUtil.tokenToUser(jedis, token).getData();
        jedis.close();

        Map<String,Integer> payPasStatusMap=paymentService.selectPayPasStatus(orderNo).getData();
        if(payPasStatusMap.get("payPasStatus")==3){
            return ServerResponse.createByStatus(ResponseCode.ORDER_ORDER_SUCCESS.getCode(),"交易已完成",null);

        }
       // Map<String,Object> map=paymentService.operAccountPeriod(orderNo,accountPeriod,interestRate).getData();
//        Double interest=(Double) map.get("interest");
//        Double currentPrincipal=(Double) map.get("currentPrincipal");
//        Double factPayment=(Double) map.get("factPayment");
//        Double unpayPeyment=(Double) map.get("unpayPeyment");
        AccountPeriodPayVo accountPeriodPayVo=new AccountPeriodPayVo();
        accountPeriodPayVo.setOrderNo(orderNo);
//        accountPeriodPayVo.setInterest(interest);
//        accountPeriodPayVo.setCurrentPrincipal(currentPrincipal);
//        accountPeriodPayVo.setUnpayPeyment(unpayPeyment);
//        accountPeriodPayVo.setInterestRate(interestRate);
        accountPeriodPayVo.setPaymentType(paymentType);
        accountPeriodPayVo.setVoucherImg(voucherImg);
        accountPeriodPayVo.setIsDeposit(0);
        accountPeriodPayVo.setTransactionNo(transactionNo);
//        accountPeriodPayVo.setAccountPeriod(accountPeriod);
//        accountPeriodPayVo.setFactPayment(factPayment);
        return  paymentService.underLineAccountPeriodPay(user.getUserId(),accountPeriodPayVo);
    }

    //传入orderNo和百分比返回金额
    @Deprecated
    @LoginRequired
    @GetMapping("getDispositPay")
    @ApiOperation(value = "获得返回的定金金额", notes = "传入定金百分比以及订单编号，2018/9/16改为全额，弃用")
    public ServerResponse getDispositPay(String token, Integer per, Long orderNo){

        return iOrderService.getDispositPay(per, orderNo);
    }

    //传入凭证相关的信息，改变订单的状态为凭证审核中
    @LoginRequired
    @PostMapping("submitOrderPaymentVoucher")
    @ApiOperation(value = "上传订单支付凭证", notes = "如果是现金订单需要转递订单编号，如果是账期用户需要传递账期编号, orderNo:订单编号, dispositPay:金额 transactionNo:流水号")
    public ServerResponse submitOrderPaymentVoucher(String token, Long orderNo, BigDecimal dispositPay, String transactionNo, String voucherImg, @RequestParam(value = "paymentType",defaultValue ="1" ) Integer paymentType) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return iOrderService.submitOrderPaymentVoucher(user.getUserId(), orderNo, dispositPay, transactionNo, voucherImg, paymentType);
    }

    @LoginRequired
    @GetMapping("deleteVoucher")
    @ApiOperation(value = "对于审核中的凭证可以进行删除")
    public ServerResponse deleteVoucher(String token, Integer voucherId) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return userService.deleteVoucher(user.getUserId(), voucherId);
    }

    //客户线下定金支付
    @Deprecated
    @LoginRequired
    @PostMapping("underLineDepositPay")
    @ApiOperation(value = "客户线下定金支付")
    public ServerResponse<AccountPeriodPayVo> underLineDepositPay(String token,String transactionNo,Long orderNo,Double deposit,String voucherImg,@RequestParam(value = "paymentType",defaultValue ="1" ) Integer paymentType ) throws Exception {
        Jedis jedis = jedisPool.getResource();
        SysUser user = tokenUtil.tokenToUser(jedis, token).getData();
        jedis.close();
        if(user==null){
            return ServerResponse.createByStatus(ResponseCode.USER_NOT_FOUND.getCode(),ResponseCode.USER_NOT_FOUND.getDesc(),null);
        }
        if(orderNo==null){
            return ServerResponse.createByStatus(ResponseCode.ORDER_SELECT_NULL.getCode(),ResponseCode.ORDER_SELECT_NULL.getDesc(),null);
        }

        return  paymentService.underLineDepositPay(user.getUserId(),orderNo,deposit,voucherImg,paymentType);
    }

    //获取支付字典
    @PostMapping("selectUnderLinePaymentDictions")
    @ApiOperation(value = "获取支付字典")
    public ServerResponse<Map<String,String>> selectUnderLinePaymentDictions()  {

        return  paymentService.selectUnderLinePaymentDictions();
    }

    //获取定金信息
    @Deprecated
    @PostMapping("selectOperDeposit")
    @ApiOperation(value = "获取定金信息")
    public ServerResponse<List<Map<String,Double>>> selectOperDeposit(Long orderNo)  {

        return  paymentService.selectDeposits(orderNo);
    }

    //获取分期数据
    @Deprecated
    @PostMapping("selectOperAccountPeriod")
    @ApiOperation(value = "获取分期数据")
    public ServerResponse<List<Map<String,Object>>> selectOperAccountPeriod(Long orderNo)  {

        return  paymentService.selectAccountPeriodsDeposits(orderNo);
    }
    //获取购买通道状态
    @Deprecated
    @PostMapping("selectPayPasStatus")
    @ApiOperation(value = "获取购买通道状态")
    public ServerResponse<Map<String,Integer>> selectPayPasStatus(Long orderNo)  {

        return  paymentService.selectPayPasStatus(orderNo);
    }
    //上传支付凭证
    @Deprecated
    @PostMapping("updateImg")
    @ApiOperation(value = "客户线下支付提交凭证信息")
    public ServerResponse<Map<String,String>> updateImg(MultipartFile file)  {

        String imgUrl;
        try {
            imgUrl=upDownService.updateHead(file);
        } catch (Exception e) {
            e.printStackTrace();
            return  ServerResponse.createByErrorMessage("上传失败");
        }
        Map<String,String> map=new HashMap<String,String>();
        map.put("voucherImg",imgUrl);
        return  ServerResponse.createBySuccess(map);
    }


    //测试设备
    @LoginRequired
    @GetMapping("test_device")
    @ApiOperation(value = "查看设备信息", notes = "ip查询地址")
    public UserDeviceVo testDevice(HttpServletRequest request, String token) throws Exception {

      return iOrderService.testDevice(request);

    }

    @LoginRequired
    @GetMapping("getOrderFufillmentList")
    @ApiOperation(value = "得到发货列表", notes = "华鼎云商获得用户自己的发货列表")
    public ServerResponse getOrderFufillmentList(String token, Long orderNo) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return iOrderService.getOrderFufillmentListorderNo(user.getUserId(), orderNo);
    }

    //确认收货
    @LoginRequired
    @PostMapping("receiveToFufillment")
    @ApiOperation(value = "对发货单进行确认收货操作", notes = "0代表不收货，1代表收货")
    public ServerResponse receiveToFufillment(String token, String orderFufillmentNo, int isReceived) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return iOrderService.receiveToFufillment(user.getUserId(), orderFufillmentNo, isReceived);

    }
    //备注
    @LoginRequired
    @PostMapping("remarkToFufillment")
    @ApiOperation(value = "对发货单进行评论操作")
    public ServerResponse remarkToFufillment(String token, String orderFufillmentNo, String remark) throws Exception {

        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        return iOrderService.remarkToFufillment(user.getUserId(), orderFufillmentNo, remark);

    }

    //订单列表页获得产品分类
    @LoginRequired
    @GetMapping("getProductType")
    @ApiOperation(value = "订单页表获得产品分类")
    public ServerResponse<List<String>> getProductType(){

        return iOrderService.getProductType();
    }


    //PC根据计划下订单
    @LoginRequired
    @PostMapping("createOrderByPlan")
    @ApiOperation(value = "根据生产计划创建订单", notes = "同时支持PC和办事处手机端下计划单，PC端不要传customerUserId, token为默认创建人，手机端传入customerUserId 用户创建\n\njsonStr说明\n" +
            "\n" + "\tInteger planItemId\n" + "\n" + "\tInteger weight\n" + "\n" + "\tBigDecimal price(业务员帮助需要价格)\n")
    public ServerResponse createOrderByPlan(String token, Integer customerUserId, String productPlanOrderJsonStr,Integer shippingId, Integer distCode, String remark, Integer transportId, @RequestParam(value = "type", defaultValue = "plan") String type) throws Exception {

        Jedis jedis = jedisPool.getResource();
        SysUser user = tokenUtil.tokenToUser(jedis, token).getData();
        jedis.close();
        int userId = user.getUserId();
        int submitPerson = 1;
        if(customerUserId != null && "".equals(customerUserId) == false){
            userId = customerUserId;
            submitPerson = 2;
        }

        return iOrderService.createOrderByPlan(userId, productPlanOrderJsonStr,shippingId, distCode, submitPerson, remark, transportId, type);
    }

    //根据凭证得到编号
    @LoginRequired
    @GetMapping(value = "getOrderNoByUser")
    @ApiOperation(value = "根据用户得到订单编号，用来获得凭证订单下拉", notes = "2018/9/26 需要")
    public ServerResponse getOrderNoByUser(String token, Integer customerUserId) throws Exception {

        Integer userId = customerUserId;
        SysUser user = tokenUtil.tokenToUser(jedisPool, token).getData();
        if(null == customerUserId || "".equals(customerUserId)){
            userId = user.getUserId();
        }

        return iOrderService.getOrderByUser(userId);
    }



}
